﻿/* ----------------------------------------------------------------------------
 * Copyright (c) Rob Ashton 2009
 *
 * This source code is subject to terms and conditions of the Microsoft Public 
 * License (Ms-PL).
 * 
 * By using this source code in any fashion, you are agreeing to be bound 
 * by the terms of the Microsoft Public License.
 * 
 * To request a copy of the Microsoft Public License, send a request by email
 * to license@mvcex.com
 *
 * This notice must not be removed from this software.
 * ---------------------------------------------------------------------------- */

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc;
using System.IO;
using System.Web;
using MvcEx.Configuration;

namespace MvcEx.Theming
{
    public class MvcExViewPage<T> : ViewPage<T> where T : class
    {
        protected override void OnPreInit(EventArgs e)
        {
            // Get the master path to work with and butcher
            String masterPath = this.MasterPageFile;

            if (!String.IsNullOrEmpty(masterPath))
            {
                this.MasterPageFile = "~/" +  MvcExThemePathResolver.ResolveThemeFileLocation(
                    MvcExThemeSystem.ThemeSelector.GetActiveTheme(),
                    MvcExConstants.THEME_DIRECTORY,
                    new HttpContextWrapper(this.Context), 
                    masterPath);
            }

            base.OnPreInit(e);
        }
    }

    public class MvcExViewPage : MvcExViewPage<Object> { }
}
